package intranet.models;
import java.sql.*;
public class AnnouncementModel {
	Connection DBConnection=null;
	public AnnouncementModel(){
		DatabaseModel DBModel=new DatabaseModel();
		DBConnection=DBModel.GetConnection();
	}
	public ResultSet SelectAnnouncement(int ann_id){
		ResultSet result=null;
		String Conditional_String=(ann_id!=0)?" WHERE ANN_ID="+ann_id:"";
		try{
			Statement ConStatement=DBConnection.createStatement();
			String Sql="SELECT ANN_ID,ANN_TITLE,ANN_DESC,FILE_NAME,FILE_PATH,DATE_POST FROM ANNOUNCEMENTS "+Conditional_String+" ORDER BY DATE_POST DESC";
			result=ConStatement.executeQuery(Sql);
		}catch(Exception e){
			e.getLocalizedMessage();
		}
		return result;
	}	
}
